

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/e-page/news/img/favicon.ico">
  <link rel="icon" href="/e-page/news/img/favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="YanpingDong">
  <meta name="keywords" content="">
  
    <meta name="description" content="index是访问首页的时候第一个展现出的内容，所以这个页面是整个网站的入口，也是最重要的页面，一般里面包括：  简单的内容列表：文章的题目、展示图片、简介、时间等简要的内容 如果超出了列表长度，则显示分页">
<meta property="og:type" content="article">
<meta property="og:title" content="怎么编写hexo主题-index 3">
<meta property="og:url" content="https://yanpingdong.gitee.io/e-page/2023/10/23/how-to-write-hexo-theme-index/index.html">
<meta property="og:site_name" content="e-page">
<meta property="og:description" content="index是访问首页的时候第一个展现出的内容，所以这个页面是整个网站的入口，也是最重要的页面，一般里面包括：  简单的内容列表：文章的题目、展示图片、简介、时间等简要的内容 如果超出了列表长度，则显示分页">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yanpingdong.gitee.io/e-page/news/2023/10/23/how-to-write-hexo-theme-index/pic/hexo_index_demo_page.png">
<meta property="article:published_time" content="2023-10-23T08:23:29.000Z">
<meta property="article:modified_time" content="2023-11-03T08:44:47.073Z">
<meta property="article:author" content="YanpingDong">
<meta property="article:tag" content="js">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://yanpingdong.gitee.io/e-page/news/2023/10/23/how-to-write-hexo-theme-index/pic/hexo_index_demo_page.png">
  
  
  
  <title>怎么编写hexo主题-index 3 - e-page</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/e-page/news/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/e-page/news/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/e-page/news/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"yanpingdong.gitee.io","root":"/e-page/news/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/e-page/news/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/e-page/news/js/utils.js" ></script>
  <script  src="/e-page/news/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 60vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/e-page/news/">
      <strong>e-page</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/../">
                <i class="iconfont icon-home-fill"></i>
                <span>Home</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/">
                <i class="iconfont icon-books"></i>
                <span>News</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>Archives</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>Categories</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>Tag</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>About</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/e-page/news/img/bg/banner.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="怎么编写hexo主题-index 3"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-10-23 16:23" pubdate>
          2023年10月23日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3.3k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          28 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">怎么编写hexo主题-index 3</h1>
            
            
              <div class="markdown-body">
                
                <p>index是访问首页的时候第一个展现出的内容，所以这个页面是整个网站的入口，也是最重要的页面，一般里面包括：</p>
<ul>
<li>简单的内容列表：文章的题目、展示图片、简介、时间等简要的内容</li>
<li>如果超出了列表长度，则显示分页</li>
</ul>
<span id="more"></span>

<p>本文的整体结构与<a href="/e-page/news/2023/10/23/how-to-write-hexo-theme-layout/">怎么编写hexo主题-layout-2</a>类似，只是更改了index.ejs。</p>
<p>主题的整体目录结构如下，多出了pagination.ejs和article-excerpt.ejs两个文件:</p>
<p><img src="/e-page/news/2023/10/23/how-to-write-hexo-theme-index/pic/hexo_diff_part_index.png" srcset="/e-page/news/img/loading.gif" lazyload></p>
<p>index.ejs的代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><br>    &lt;% page.posts.each(function(item, index)&#123; %&gt;<br>    &lt;%- partial(&#x27;_partial/article-excerpt&#x27;, &#123;item: item, index:index+1&#125;) %&gt;<br>    &lt;% &#125;); %&gt;<br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br>&lt;%- partial(&#x27;_partial/pagination&#x27;) %&gt;<br></code></pre></td></tr></table></figure>

<p>上面的EJS代码解释：</p>
<ol>
<li>遍历所有文章，并显示文章的标题、简介、时间等简要信息。每个文章的细节，因为每一个文章的简介只是替换里面的内容,结构不变，所以提取article-excerpt作为同样的模板。</li>
<li>显示分页。这个分页的代码，因为分页的代码是固定的，所以提取pagination作为同样的模板。</li>
</ol>
<p>所以整体的逻辑如下：</p>
<ul>
<li>首先，使用<code>page.posts</code>获取文章列表，然后遍历文章列表，使用<code>partial</code>函数，将文章列表的每一个文章，渲染到article-excerpt模板中。</li>
<li>然后，使用<code>partial</code>函数，将分页的代码渲染到pagination模板中。</li>
</ul>
<p>article-excerpt的代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;&lt;%- config.root %&gt;&lt;%- item.path %&gt;&quot;</span> &gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span>  <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;background-image: url(&lt;%- config.root %&gt;&lt;%- item.featured_image || theme.featured_image %&gt;); width: 200px; height: 120px;&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">article</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><br>        title: &lt;%=item.title %&gt; -- index: &lt;%=index %&gt;<br>      <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br>      &lt;% if(index != 1)&#123; %&gt;<br>        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><br>          &lt;%- item.summary || item.excerpt %&gt;<br>        <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>      &lt;% &#125; %&gt;<br>      <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><br>        &lt;%= item.date.format(config.date_format) %&gt;<br>      <span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">article</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>pagination的代码如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>pagination part<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;&lt;%- config.root %&gt;&lt;%- page.prev_link %&gt;&quot;</span>&gt;</span>(&lt;=)前一页: &lt;%- page.prev_link %&gt;<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>---<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;&lt;%- config.root %&gt;&lt;%- page.next_link %&gt;&quot;</span>&gt;</span>后一页(=&gt;): &lt;%- page.next_link %&gt;<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h1 id="示例结果"><a href="#示例结果" class="headerlink" title="示例结果"></a>示例结果</h1><p>从新启动hexo，可以看到文章列表，整体结构和之前<a href="/e-page/news/2023/10/23/how-to-write-hexo-theme-layout/">怎么编写hexo主题-layout 2</a>没什么变化，页面如下：</p>
<p><img src="/e-page/news/2023/10/23/how-to-write-hexo-theme-index/pic/hexo_index_demo_page.png" srcset="/e-page/news/img/loading.gif" lazyload></p>
<p>之前main之间的内容已经被新修改的index.ejs替换掉了，旧的如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello World, Index Page Content<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h1 id="layout-ejs与index-ejs-archive-ejs-tag-ejs-category-ejs-post-ejs的关系"><a href="#layout-ejs与index-ejs-archive-ejs-tag-ejs-category-ejs-post-ejs的关系" class="headerlink" title="layout.ejs与index.ejs&#x2F;archive.ejs&#x2F;tag.ejs&#x2F;category.ejs&#x2F;post.ejs的关系"></a>layout.ejs与index.ejs&#x2F;archive.ejs&#x2F;tag.ejs&#x2F;category.ejs&#x2F;post.ejs的关系</h1><p>实际的index.ejs&#x2F;archive.ejs&#x2F;tag.ejs&#x2F;category.ejs&#x2F;post.ejs都是layout.ejs的内容子模板，layout.ejs在不同的页面会使用不同的子模板来渲染替换<code>&lt;%- body %&gt;</code>。</p>
<p>现在在看下下面的表格，体会就懂了。</p>
<table>
<thead>
<tr>
<th>功能</th>
<th>访问路径</th>
<th>对应layout中body的文件名</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>入口</td>
<td>无或&#x2F;</td>
<td>&#x2F;layout&#x2F;index.ejs</td>
<td>主题入口,&lt;%- body %&gt;值是&#x2F;layout&#x2F;index.ejs</td>
</tr>
<tr>
<td>归档</td>
<td>&#x2F;archives&#x2F;</td>
<td>&#x2F;layout&#x2F;archive.ejs</td>
<td>归档，包含所有的文章，一般按文章的时间排序，内置支持！</td>
</tr>
<tr>
<td>分类</td>
<td>&#x2F;categories&#x2F;</td>
<td>&#x2F;layout&#x2F;category.ejs</td>
<td>显示全部分类文章，含分页，没内置支持！</td>
</tr>
<tr>
<td>具体分类</td>
<td>&#x2F;categories&#x2F;{category}&#x2F;</td>
<td>&#x2F;layout&#x2F;category.ejs</td>
<td>显示指定类型分类的页面，含分页;&lt;%- body %&gt;值的优先填充是&#x2F;layout&#x2F;category.ejs&gt;&#x2F;layout&#x2F;archive.ejs&gt;&#x2F;layout&#x2F;index.ejs</td>
</tr>
<tr>
<td>标签</td>
<td>&#x2F;tags&#x2F;</td>
<td>&#x2F;layout&#x2F;tag.ejs</td>
<td>显示全部标签，含分页，没内置支持！</td>
</tr>
<tr>
<td>具体标签</td>
<td>&#x2F;tags&#x2F;{tag}&#x2F;</td>
<td>&#x2F;layout&#x2F;tag.ejs</td>
<td>显示某一个标签的页面，含分页；&lt;%- body %&gt;值的优先填充是&#x2F;layout&#x2F;tag.ejs&gt;&#x2F;layout&#x2F;archive.ejs&gt;&#x2F;layout&#x2F;index.ejs</td>
</tr>
<tr>
<td>博客内容</td>
<td>&#x2F;年&#x2F;月&#x2F;日&#x2F;博客的文件名称&#x2F;</td>
<td>&#x2F;layout&#x2F;post.ejs</td>
<td>具体一篇文章的详细内容页面，一般包含前一篇和后一篇的功能,请注意和分页功能不同，一页可以有多个文章！</td>
</tr>
<tr>
<td>自定义页面</td>
<td>&#x2F;页眉路径&#x2F;</td>
<td>&#x2F;layout&#x2F;custum-page.ejs</td>
<td>比如about界面，自定的名称就是页眉路径，about就是&#x2F;about&#x2F;</td>
</tr>
</tbody></table>
<h1 id="article-excerpt渲染"><a href="#article-excerpt渲染" class="headerlink" title="article-excerpt渲染"></a>article-excerpt渲染</h1><p>该模板是用来渲染文章的简介方便用户简单查看，hexo会提取md文件中的数据，以供article-excerpt模板使用，md中的内容如下：</p>
<figure class="highlight md"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs md">---<br>title: demo<span class="hljs-emphasis">_1</span><br><span class="hljs-emphasis">tags: show</span><br><span class="hljs-emphasis">date: 2023-10-23 15:11:56</span><br><span class="hljs-emphasis">summary: demo_</span>1 summary<br>---<br></code></pre></td></tr></table></figure>

<p>theme的_config.yml</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk"><span class="hljs-comment"># If featured_image is missing from a post, this one will be used.</span><br>featured_image: .<span class="hljs-regexp">/img/</span>default.jpg<br></code></pre></td></tr></table></figure>

<p>模板渲染后的结果如下：</p>
<p><img src="/e-page/news/2023/10/23/how-to-write-hexo-theme-index/pic/article_excerpt_filled.png" srcset="/e-page/news/img/loading.gif" lazyload></p>
<p><strong>欢迎关注微信公众号，更多文章分享。</strong> <img src="/e-page/news/img/qrcode_for_ITSuperDaddy.jpg" srcset="/e-page/news/img/loading.gif" lazyload></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/e-page/news/categories/%E5%89%8D%E7%AB%AF/" class="category-chain-item">前端</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/e-page/news/tags/js/" class="print-no-link">#js</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>怎么编写hexo主题-index 3</div>
      <div>https://yanpingdong.gitee.io/e-page/2023/10/23/how-to-write-hexo-theme-index/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>YanpingDong</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年10月23日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/e-page/news/2023/10/24/how-to-write-hexo-theme-post/" title="怎么编写hexo主题-post 4">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">怎么编写hexo主题-post 4</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/e-page/news/2023/10/23/how-to-write-hexo-theme-layout/" title="怎么编写hexo主题-layout 2">
                        <span class="hidden-mobile">怎么编写hexo主题-layout 2</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>E-page</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/e-page/news/js/events.js" ></script>
<script  src="/e-page/news/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/e-page/news/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/e-page/news/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/e-page/news/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
